package controllers;

import models.UserRule;
import play.mvc.Controller;
import util.Base64Coder;
import util.PacGenerator;

public class Pac extends Controller {
	public static void index(String userName) {
		UserRule userRule = UserRule.find("byUserName", userName).first();
		String userRules = userRule == null ? "" : userRule.rules;
		PacGenerator pg = new PacGenerator(userRules);
		String pacText = Base64Coder.encodeString(pg.getPac("localhost", 7070));
		// String pacText = pg.getPac("localhost", 7070);
		renderTemplate("Pac/index.pac", pacText);
	}
}
